# This is an API workspace, having public visibility by default makes perfect sense.
package(default_visibility = ["//visibility:public"])

##############################################################################
# Common
##############################################################################
load("@com_google_googleapis_imports//:imports.bzl", "proto_library_with_info")

proto_library(
    name = "cel_service_proto",
    srcs = ["cel_service.proto"],
    deps = [
        ":conformance_service_proto",
    ],
)

proto_library(
    name = "checked_proto",
    srcs = ["checked.proto"],
    deps = [
        ":syntax_proto",
        "@com_google_protobuf//:empty_proto",
        "@com_google_protobuf//:struct_proto",
    ],
)

proto_library(
    name = "conformance_service_proto",
    srcs = ["conformance_service.proto"],
    deps = [
        ":checked_proto",
        ":eval_proto",
        ":syntax_proto",
        "//google/api:client_proto",
        "//google/api:field_behavior_proto",
        "//google/rpc:status_proto",
    ],
)

proto_library(
    name = "eval_proto",
    srcs = ["eval.proto"],
    deps = [
        ":value_proto",
        "//google/rpc:status_proto",
    ],
)

proto_library(
    name = "explain_proto",
    srcs = ["explain.proto"],
    deps = [
        ":value_proto",
    ],
)

proto_library(
    name = "syntax_proto",
    srcs = ["syntax.proto"],
    deps = [
        "@com_google_protobuf//:duration_proto",
        "@com_google_protobuf//:struct_proto",
        "@com_google_protobuf//:timestamp_proto",
    ],
)

proto_library(
    name = "value_proto",
    srcs = ["value.proto"],
    deps = [
        "@com_google_protobuf//:any_proto",
        "@com_google_protobuf//:struct_proto",
    ],
)

proto_library(
    name = "cel_proto",
    srcs = [
        "cel_service.proto",
        "checked.proto",
        "conformance_service.proto",
        "eval.proto",
        "explain.proto",
        "syntax.proto",
        "value.proto",
    ],
    deps = [
        "//google/api:client_proto",
        "//google/api:field_behavior_proto",
        "//google/rpc:status_proto",
        "@com_google_protobuf//:any_proto",
        "@com_google_protobuf//:duration_proto",
        "@com_google_protobuf//:empty_proto",
        "@com_google_protobuf//:struct_proto",
        "@com_google_protobuf//:timestamp_proto",
    ],
)

proto_library_with_info(
    name = "cel_proto_with_info",
    deps = [
        ":cel_proto",
        "//google/cloud:common_resources_proto",
    ],
)

##############################################################################
# Java
##############################################################################
load(
    "@com_google_googleapis_imports//:imports.bzl",
    "java_grpc_library",
    "java_gapic_library",
    "java_gapic_assembly_gradle_pkg",
    "java_proto_library",
    "java_gapic_test",
)

java_proto_library(
    name = "cel_java_proto",
    deps = [":cel_proto"],
)

java_grpc_library(
    name = "cel_java_grpc",
    srcs = [":cel_proto"],
    deps = [":cel_java_proto"],
)

java_gapic_library(
    name = "cel_java_gapic",
    src = ":cel_proto_with_info",
    gapic_yaml = "cel_gapic.yaml",
    service_yaml = "//google/api/expr:cel.yaml",
    test_deps = [":cel_java_grpc"],
    deps = [":cel_java_proto"],
)

java_gapic_test(
    name = "cel_java_gapic_test_suite",
    test_classes = [
        "com.google.cloud.api.expr.v1alpha1.CelServiceClientTest",
        "com.google.cloud.api.expr.v1alpha1.ConformanceServiceClientTest",
    ],
    runtime_deps = [":cel_java_gapic_test"],
)

# Opensource Packages
java_gapic_assembly_gradle_pkg(
    name = "google-cloud-cel-v1alpha1-java",
    deps = [
        ":cel_java_gapic",
        ":cel_java_grpc",
        ":cel_java_proto",
        ":cel_proto",
    ],
)

##############################################################################
# Go
##############################################################################
load(
    "@com_google_googleapis_imports//:imports.bzl",
    "go_proto_library",
    "go_test",
    "go_gapic_library",
    "go_gapic_assembly_pkg",
)

go_proto_library(
    name = "cel_go_proto",
    compilers = ["@io_bazel_rules_go//proto:go_grpc"],
    importpath = "google.golang.org/genproto/googleapis/api/expr/v1alpha1",
    protos = [":cel_proto"],
    deps = [
        "//google/api:annotations_go_proto",
        "//google/rpc:status_go_proto",
    ],
)

go_gapic_library(
    name = "cel_go_gapic",
    src = ":cel_proto_with_info",
    gapic_yaml = "cel_gapic.yaml",
    importpath = "cloud.google.com/go/expr/apiv1alpha1",
    service_yaml = "//google/api/expr:cel.yaml",
    deps = [":cel_go_proto"],
)

go_test(
    name = "cel_go_gapic_test",
    srcs = [":cel_go_gapic_srcjar_test"],
    embed = [":cel_go_gapic"],
    importpath = "cloud.google.com/go/expr/apiv1alpha1",
)

# Opensource Packages
go_gapic_assembly_pkg(
    name = "gapi-cloud-cel-v1alpha1-go",
    deps = [
        ":cel_go_gapic",
        ":cel_go_gapic_srcjar-smoke-test.srcjar",
        ":cel_go_gapic_srcjar-test.srcjar",
        ":cel_go_proto",
    ],
)

##############################################################################
# C++
##############################################################################
load(
    "@com_google_googleapis_imports//:imports.bzl",
    "cc_grpc_library",
    "cc_proto_library",
)

cc_proto_library(
    name = "cel_service_cc_proto",
    deps = [":cel_service_proto"],
)

cc_grpc_library(
    name = "cel_service_cc_grpc",
    srcs = [":cel_service_proto"],
    generate_mocks = True,
    grpc_only = True,
    deps = [":cel_service_cc_proto"],
)

cc_proto_library(
    name = "checked_cc_proto",
    deps = [":checked_proto"],
)

cc_proto_library(
    name = "conformance_service_cc_proto",
    deps = [":conformance_service_proto"],
)

cc_grpc_library(
    name = "conformance_service_cc_grpc",
    srcs = [":conformance_service_proto"],
    generate_mocks = True,
    grpc_only = True,
    deps = [":conformance_service_cc_proto"],
)

cc_proto_library(
    name = "eval_cc_proto",
    deps = [":eval_proto"],
)

cc_proto_library(
    name = "explain_cc_proto",
    deps = [":explain_proto"],
)

cc_proto_library(
    name = "syntax_cc_proto",
    deps = [":syntax_proto"],
)

cc_proto_library(
    name = "value_cc_proto",
    deps = [":value_proto"],
)

##############################################################################
# Python
##############################################################################
load("@com_google_googleapis_imports//:imports.bzl", "py_proto_library")

py_proto_library(
    name = "checked_py_proto",
    deps = [":checked_proto"],
)

py_proto_library(
    name = "eval_py_proto",
    deps = [":eval_proto"],
)

py_proto_library(
    name = "explain_py_proto",
    deps = [":explain_proto"],
)

py_proto_library(
    name = "syntax_py_proto",
    deps = [":syntax_proto"],
)

py_proto_library(
    name = "value_py_proto",
    deps = [":value_proto"],
)
